<?php
/**
 * Manageaccount_Model_Manageaccount
 * manageaccount main model implementation
 * 
 * @author Adrian Stolarski
 */
class Manageaccount_Model_Manageaccount implements Manageaccount_Model_Mainable, 
        Manageaccount_Model_Selectable {
    
    /**
     *
     * @var type $login_redirect
     * login redirect handler
     */
    public $login_redirect;
    /**
     *
     * @var type $action_handler
     * current action handler
     */
    public $action_handler;
    
    /**
     * main()
     * session decision
     * 
     * @param array $variables
     * @return type array $select_data
     */
    public function main(array $variables = null) {
        if(
                isset($_SESSION['user_id']) 
                && ($_SESSION['user_id'] != 0) 
                && isset($_SESSION['access_level_id']) 
                && ($_SESSION['access_level_id'] != 0)
                ){
            return $this->select_action($variables);
        }
        else {
            $this->login_redirect = new Login_Data_Loginredirect;
            $this->login_redirect->main($variables);
        }
    }

    public function select_action(array $variables = null) {
        switch($variables['get']['name']){
            case 'current_user':
                return $this->get_user_data($variables);
                break;
            case '':
                break;
            case '':
                break; 
            default: 
                $this->get_user_data($variables);
                break;
        }
    }
    
    /**
     * get user_data()
     * get current user data 
     * 
     * @param array $variables
     * @return type $page
     */
    private function get_user_data(array $variables = null){
        $this->action_handler = new Manageaccount_Data_Currentaccount;
        return $this->action_handler->main($variables['post']);
    }

}
